using System.Drawing;

using SharpWind.Gui.Controls;
using SharpWind.Input;
using Microsoft.DirectX.Direct3D;

namespace SharpWind.Gui
{
	public class MouseCursor : Control
	{
		public MouseCursor()
		{
			Location = new Point( 0, 0 );
		}

		internal override void Render()
		{
			if( Visible )
			{
				Engine.Instance.Renderer.GuiSprite.Begin( SpriteFlags.AlphaBlend );

				Theme theme = Engine.Instance.Scene.Controls.Theme;
				Theme.Control cursor = theme.Controls["mousecursor"];

				// NormalCursor
				Theme.Control.Element element = cursor.Elements["NormalCursor"];
				
				Engine.Instance.Renderer.GuiSprite.Draw2D( theme.Texture.D3DTexture,
				                                           new Rectangle( element.X, element.Y, element.Width, element.Height ),
				                                           new Size( element.Width, element.Height ),
				                                           new PointF( Location.X, Location.Y ), element.Color );

				Engine.Instance.Renderer.GuiSprite.End();
			}
		}

		internal override void MouseMove( MouseEventArgs e )
		{
			if( Enabled && Visible )
			{
				Location = new Point( e.AbsX, e.AbsY );
			}
		}
	}
}